package br.odb.libscene;

import java.util.ArrayList;

import br.odb.utils.math.Vec3;

public class SceneObject {
	private ArrayList<Mesh> meshes;	
	private Vec3 origin;
	private Vec3 dimensions;
	private short emissiveLightningIntensity;
	private boolean visible;
	
	/**
	 * @return the visible
	 */
	public boolean isVisible() {
		return visible;
	}

	/**
	 * @param visible the visible to set
	 */
	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	public SceneObject() {
		visible = true;
		meshes = new ArrayList<Mesh>();
		origin = new Vec3();
		dimensions = new Vec3();
	}
	
	public SceneObject( SceneObject sceneObject ) {
		//meshes = new Vector( sceneObject.meshes );
		meshes = new ArrayList<Mesh>();
		int size = sceneObject.meshes.size();
		
		for ( int c = 0; c < size; ++c )
			meshes.add( sceneObject.meshes.get( c ) );
		
		visible = sceneObject.isVisible();
		origin = new Vec3( sceneObject.origin );
		dimensions = new Vec3( sceneObject.dimensions );
		emissiveLightningIntensity = sceneObject.emissiveLightningIntensity;
	}

	public short getEmissiveLightningIntensity() {
		return emissiveLightningIntensity;
	}
	
	public void setEmissiveLightningIntensity( short candelas) {
		emissiveLightningIntensity = candelas;
	}
	
	public void addCandelas( short candelas) {
		emissiveLightningIntensity += candelas;
		
		if (emissiveLightningIntensity >= Byte.MAX_VALUE)
			emissiveLightningIntensity = Byte.MAX_VALUE;
	}
	
	public void moveTo( Vec3 place ) {
		Vec3 diff = place.sub( origin );
		move( diff );
		origin.copy( place );
	}
	
	public void move( Vec3 delta ) {
		origin.set( origin.add( delta ) );
	}
	
	public void setPosition( Vec3 v ) {
		this.origin.set( v );		
	}
	
	public ArrayList<Mesh> getMeshes( ) {
		return meshes;
	}
	
	public void update() {
		
	}
	
	public void addMesh( Mesh mesh ) {
		meshes.add( mesh );
	}
	
	public Vec3 getPosition() {
		return origin;
	}
}
